package com.javase.grammar;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liyanhao9999@outlook.com
 * @date 2022/5/31 21:19
 */
public class TestFinally {
    public static void main(String[] args) {
        System.out.println(getReturn());
        System.out.println(getReturnMap().get("key"));
    }

    public static int getReturn() {
        int result = 2;
        try {
            ++result;
            return result;
        } catch (Exception e) {

        } finally {
            result++;
            System.out.println(result);
        }
        return result;
    }

    public static Map getReturnMap() {
        HashMap<String, Object> map = new HashMap<>();
        try {
            map.put("key", "3");
        } catch (Exception e) {

        } finally {
            map.put("key", "4");
            System.out.println(map.get("key"));
        }
        return map;
    }
}
